//
//  TMUserViewModel.m
//  国学培训用户端
//
//  Created by Tao Li on 2018/8/16.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "TMUserViewModel.h"
#import "TMUserInformationModel.h"
#import "TMMyCourseModel.h"
#import "TMMyOrderModel.h"
#import "TMCollectionModel.h"
#import "TMDiscountModel.h"
#import "TMCourseDetailModel.h"
#import "TMInvitationMoneyModel.h"
#import "TMVipModel.h"
#import "TMPushModel.h"
#import "TMComplaintModel.h"
@interface TMUserViewModel()
@property (nonatomic, strong) NSMutableArray *allList;
@property (nonatomic, strong) NSMutableArray *teacherList;

@end
@implementation TMUserViewModel
- (NSMutableArray *)allList {
    if (_allList ==nil) {
        _allList = [NSMutableArray array];
    }return _allList;
}
- (NSMutableArray *)teacherList {
    if (_teacherList ==nil) {
        _teacherList = [NSMutableArray array];
    }return _teacherList;
}

-(void)getMyPageDataSuccess:(SuccessBlock)success failed:(FailureBlock)failed{
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_GetUserInformation parameters:param method:TMDataRequestTypePost prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        TMUserInformationModel *model = [TMUserInformationModel yy_modelWithJSON:responseObject[@"list"]];
        model.coll_goods = [responseObject[@"data"][@"coll_goods"] integerValue];
        model.coll_shop = [responseObject[@"data"][@"coll_shop"] integerValue];
        model.history = [responseObject[@"data"][@"history"] integerValue];
        model.com = [responseObject[@"data"][@"com"] integerValue];
        model.over = [responseObject[@"data"][@"over"] integerValue];
        model.ret = [responseObject[@"data"][@"ret"] integerValue];
        model.tip = [responseObject[@"data"][@"tip"] integerValue];
        model.rank = responseObject[@"rank"];
        success(model);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        NSLog(@"%@", errorMessage);
        failed(errorMessage);
        //[TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
        NSLog(@"%@", error.description);
    }];
}
-(void)getUserSettingsDataSuccess:(SuccessBlock)success failed:(FailureBlock)failed{
    [self.teacherList removeAllObjects];
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_UserSettings parameters:param method:0 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        TMUserSettingCardsModel *model = [TMUserSettingCardsModel yy_modelWithJSON:responseObject[@"account"]];
        TMUserSettingModel *models = [TMUserSettingModel yy_modelWithJSON:responseObject[@"list"]];
        model.qq = [responseObject[@"qq"] description];
        model.wei = [responseObject[@"wei"] description];
        model.band_name = [TMBandModel yy_modelWithJSON:responseObject[@"band_name"]];
        [self.teacherList addObject:model];
        [self.teacherList addObject:models];
        success(self.teacherList);
        
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        NSLog(@"%@", errorMessage);
        failed(errorMessage);
        //[TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
        NSLog(@"%@", error.description);
    }];
}
-(void)changeNickName:(NSString *)nick Success:(SuccessBlock)success failed:(FailureBlock)failed{
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [param setValue:nick forKey:@"nickname"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_ChangeNickName parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        [TMProgressHUD showSuccessWithStyleDarkStatus:@"修改成功！"];
        success(responseObject);
        
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        NSLog(@"%@", errorMessage);
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
        NSLog(@"%@", error.description);
    }];
}
-(void)changeUserIcon:(NSString *)head Success:(SuccessBlock)success failed:(FailureBlock)failed{
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [param setValue:head forKey:@"head"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_ChangeUserIcon parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        [TMProgressHUD showSuccessWithStyleDarkStatus:@"修改成功！"];
        success(responseObject);
        
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        NSLog(@"%@", errorMessage);
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
        NSLog(@"%@", error.description);
    }];
}




-(void)changeMail:(NSString *)mail Success:(SuccessBlock)success failed:(FailureBlock)failed{
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [param setValue:mail forKey:@"mail"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_ChangeMail parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        [TMProgressHUD showSuccessWithStyleDarkStatus:@"修改成功！"];
        success(responseObject);
        
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        NSLog(@"%@", errorMessage);
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
        NSLog(@"%@", error.description);
    }];
}

-(void)changePhone:(NSString *)mail AndCode:(NSString *)code Success:(SuccessBlock)success failed:(FailureBlock)failed{
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [param setValue:mail forKey:@"phone"];
    [param setValue:code forKey:@"code"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_ChangePhone parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        [TMProgressHUD showSuccessWithStyleDarkStatus:@"修改成功！"];
        success(responseObject);
        
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        NSLog(@"%@", errorMessage);
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
        NSLog(@"%@", error.description);
    }];
}

-(void)BlindZSCard:(NSString *)name AndCard:(NSString *)card Success:(SuccessBlock)success failed:(FailureBlock)failed{
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [param setValue:card forKey:@"zs_card"];
    [param setValue:name forKey:@"zs_name"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_BlindZSBankCard parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        [TMProgressHUD showSuccessWithStyleDarkStatus:@"修改成功！"];
        success(responseObject);
        
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
    }];
}
-(void)BlindWX:(NSString *)name AndCard:(NSString *)card Success:(SuccessBlock)success failed:(FailureBlock)failed{
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [param setValue:card forKey:@"wx_card"];
    [param setValue:name forKey:@"wx_name"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_BlindWX parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        [TMProgressHUD showSuccessWithStyleDarkStatus:@"修改成功！"];
        success(responseObject);
        
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
    }];
}
-(void)BlindWB:(NSString *)name AndCard:(NSString *)card Success:(SuccessBlock)success failed:(FailureBlock)failed{
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [param setValue:card forKey:@"wb_card"];
    [param setValue:name forKey:@"wb_name"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_BlindWB parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        [TMProgressHUD showSuccessWithStyleDarkStatus:@"修改成功！"];
        success(responseObject);
        
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
    }];
}
-(void)BlindZFB:(NSString *)name AndCard:(NSString *)card Success:(SuccessBlock)success failed:(FailureBlock)failed{
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [param setValue:card forKey:@"zfb_card"];
    [param setValue:name forKey:@"zfb_name"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_BlindZfb parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        [TMProgressHUD showSuccessWithStyleDarkStatus:@"修改成功！"];
        success(responseObject);
        
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
    }];
}

-(void)getMyCourseSuccess:(SuccessBlock)success failed:(FailureBlock)failed{
    [self.teacherList removeAllObjects];
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_GetMyCourse parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSMutableArray *arr = [NSMutableArray array];
        for (NSDictionary *dic in responseObject[@"record"]) {
            TMMyCourseModel *model = [TMMyCourseModel yy_modelWithJSON:dic];
            [arr addObject:model];
        }
        [self.teacherList addObjectsFromArray:arr];
        success(self.teacherList);
        
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
    }];
}

-(void)getMyCourseDetailWith:(NSInteger)tid And:(NSInteger)oid Success:(SuccessBlock)success failed:(FailureBlock)failed{
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [param setValue:@(tid) forKey:@"id"];
    [param setValue:@(oid) forKey:@"order_id"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_GetMyCourseDetail parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSMutableArray *arr = [NSMutableArray array];
        for (NSDictionary *dic in responseObject[@"record"]) {
            TMRecordsModel *model = [TMRecordsModel yy_modelWithJSON:dic];
            [arr addObject:model];
        }
        [self.teacherList addObject:arr];
        TMCourseDetailModel *models = [TMCourseDetailModel yy_modelWithJSON:responseObject[@"course"]];
        models.url = responseObject[@"url"];
        [self.teacherList addObject:models];
        success(self.teacherList);
        
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
    }];
}
-(void)getOrderCourseDetailWith:(NSInteger)tid And:(NSInteger)oid Success:(SuccessBlock)success failed:(FailureBlock)failed{
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [param setValue:@(tid) forKey:@"id"];
    [param setValue:@(oid) forKey:@"bid"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_OrderCourseDetail parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSMutableArray *arr = [NSMutableArray array];
//        for (NSDictionary *dic in responseObject[@"record"]) {
//            TMRecordsModel *model = [TMRecordsModel yy_modelWithJSON:dic];
//            [arr addObject:model];
//        }
        [self.teacherList addObject:arr];
        TMCourseDetailModel *models = [TMCourseDetailModel yy_modelWithJSON:responseObject[@"course"]];
        models.url = responseObject[@"url"];
        [self.teacherList addObject:models];
        success(self.teacherList);
        
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
    }];
}



-(void)getMyOrderWithStatus:(NSInteger)status Success:(SuccessBlock)success failed:(FailureBlock)failed{
    [self.teacherList removeAllObjects];
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [param setValue:@(status) forKey:@"status"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_GetMyOrder parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        NSMutableArray *arr = [NSMutableArray array];
        for (NSDictionary *dic in responseObject[@"list"]) {
            TMMyOrderModel *model = [TMMyOrderModel yy_modelWithJSON:dic];
            [arr addObject:model];
        }
        [self.teacherList addObjectsFromArray:arr];
        success(self.teacherList);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
    }];
}
#pragma --mark 收藏 删除收藏
-(void)getCommityCollectionPage:(NSInteger)page Success:(CompleteBlock)success failed:(FailureBlock)failed{
    if (page == 1) {
        [self.teacherList removeAllObjects];
    }
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [param setValue:@(page) forKey:@"page"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_CommityCollection parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        NSMutableArray *arr = [NSMutableArray array];
        for (NSDictionary *dic in responseObject[@"data"]) {
            TMCollectionModel *model = [TMCollectionModel yy_modelWithJSON:dic];
            [arr addObject:model];
        }
        [self.teacherList addObjectsFromArray:arr];
        success(self.teacherList, responseObject[@"total"]);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
    }];
}
#pragma --mark 取消收藏
-(void)deleteCommityCollection:(NSString *)commityID Success:(SuccessBlock)success failed:(FailureBlock)failed{
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [param setObject:commityID forKey:@"id"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_deleteCommityCollection parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        [TMProgressHUD showSuccessWithStyleDarkStatus:@"取消收藏成功！"];
        success(self.teacherList);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
    }];
}

-(void)getShopCollectionAndPage:(NSInteger)page Success:(CompleteBlock)success failed:(FailureBlock)failed{
    if (page == 1) {
        [self.teacherList removeAllObjects];
    }
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [param setValue:@(page) forKey:@"page"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_ShopCollection parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        NSMutableArray *arr = [NSMutableArray array];
        for (NSDictionary *dic in responseObject[@"data"]) {
            TMCollectionModel *model = [TMCollectionModel yy_modelWithJSON:dic];
            [arr addObject:model];
        }
        [self.teacherList addObjectsFromArray:arr];
        success(self.teacherList,responseObject[@"total"]);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
    }];
}
-(void)deleteShopCollection:(NSInteger)commityID Success:(SuccessBlock)success failed:(FailureBlock)failed{
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    NSArray *arr = [NSArray arrayWithObject:@(commityID)];
    NSString *json = [SPToolSet arrayToJSONString:arr];
    [param setValue:json forKey:@"id"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_deleteShopCollection parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
         [TMProgressHUD showSuccessWithStyleDarkStatus:@"取消收藏成功！"];
        success(self.teacherList);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
    }];
}

-(void)getFooterCollection:(NSInteger)commityID Page:(NSInteger)page Success:(CompleteBlock)success failed:(FailureBlock)failed{
    if (page == 1) {
        [self.teacherList removeAllObjects];
    }
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [param setValue:@(commityID) forKey:@"type"];
    [param setValue:@(page) forKey:@"page"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_FooterCollection parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        NSMutableArray *arr = [NSMutableArray array];
        for (NSDictionary *dic in responseObject[@"data"]) {
            TMCollectionModel *model = [TMCollectionModel yy_modelWithJSON:dic];
            [arr addObject:model];
        }
        [self.teacherList addObjectsFromArray:arr];
        success(self.teacherList, responseObject[@"total"]);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
    }];
}
-(void)deleteFooterCollection:(NSInteger)commityID Success:(SuccessBlock)success failed:(FailureBlock)failed{
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    NSArray *arr = [NSArray arrayWithObject:@(commityID)];
    NSString *json = [SPToolSet arrayToJSONString:arr];
    [param setValue:json forKey:@"id"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_deleteFooterCollection parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        [TMProgressHUD showSuccessWithStyleDarkStatus:@"删除成功！"];
        success(self.teacherList);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
    }];
}
#pragma --mark 购物车数据
-(void)getShoppingCartSuccess:(SuccessBlock)success failed:(FailureBlock)failed{
    [self.teacherList removeAllObjects];
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_ShoppingCart parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        NSMutableArray *arr = [NSMutableArray array];
        for (NSDictionary *dic in responseObject[@"list"]) {
            TMMyCartModel *model = [TMMyCartModel yy_modelWithJSON:dic];
            model.rank = [responseObject[@"rank"] integerValue];
            [arr addObject:model];
        }
        [self.teacherList addObjectsFromArray:arr];
        success(self.teacherList);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
    }];
}
#pragma --mark 我的优惠券
-(void)getMyDiscountSuccess:(SuccessBlock)success failed:(FailureBlock)failed{
    [self.teacherList removeAllObjects];
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_MyDiscount parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        NSMutableArray *arr = [NSMutableArray array];
        for (NSDictionary *dic in responseObject[@"data"]) {
            TMDiscountModel *model = [TMDiscountModel yy_modelWithJSON:dic];
            [arr addObject:model];
        }
        [self.teacherList addObjectsFromArray:arr];
        success(self.teacherList);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
    }];
}
#pragma --mark 评论
-(void)getCommitCommendWith:(NSDictionary *)dic Success:(SuccessBlock)success failed:(FailureBlock)failed{
//    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_MyCommitCommend parameters:dic method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        
        success(responseObject);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
    }];
}


-(void)getCommitCollectionWith:(NSInteger)cid Success:(SuccessBlock)success failed:(FailureBlock)failed{
    NSMutableDictionary *dic = [TMUserManager paramDisplay];
    [dic setValue:@(cid) forKey:@"coures_id"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_GetCommityCollection parameters:dic method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        [TMProgressHUD showSuccessWithStyleDarkStatus:responseObject[@"msg"]];
        success(responseObject);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showErrorWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showErrorWithStyleDarkStatus:@"网络错误！"];
    }];
}
- (void)deleteShoppingCartParam:(id)fid Success:(SuccessBlock)block Failed:(FailureBlock)failre{
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [param setValue:fid forKey:@"id"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_DeleteShoppingCart parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        [TMProgressHUD showSuccessWithStyleDarkStatus:responseObject[@"msg"]];
        block(responseObject);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failre(errorMessage);
        [TMProgressHUD showSuccessWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failre(@"1");
    }];
}
- (void)PaySuccessSuccess:(SuccessBlock)block Failed:(FailureBlock)failre{
    [self.teacherList removeAllObjects];
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_PaySuccess parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSMutableArray *arr = [NSMutableArray array];
        for (NSDictionary *dic in responseObject[@"data"]) {
            TMMyCartModel *model = [TMMyCartModel yy_modelWithJSON:dic];
            [arr addObject:model];
        }
        [self.teacherList addObjectsFromArray:arr];
        [TMProgressHUD showSuccessWithStyleDarkStatus:responseObject[@"msg"]];
        block(self.teacherList);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failre(errorMessage);
        [TMProgressHUD showSuccessWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failre(@"1");
    }];
}
//TMAPI_CourseOrderResult
#pragma --mark 预约的课程
- (void)getCourseOrderSuccessSuccess:(SuccessBlock)block Failed:(FailureBlock)failre{
    [self.teacherList removeAllObjects];
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_CourseOrderResult parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSMutableArray *arr = [NSMutableArray array];
        for (NSDictionary *dic in responseObject[@"data"]) {
            TMMyCourseModel *model = [TMMyCourseModel yy_modelWithJSON:dic];
            [arr addObject:model];
        }
        [self.teacherList addObjectsFromArray:arr];
        [TMProgressHUD showSuccessWithStyleDarkStatus:responseObject[@"msg"]];
        block(self.teacherList);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failre(errorMessage);
        [TMProgressHUD showSuccessWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failre(@"1");
    }];
}
#pragma --mark 开课提醒
- (void)getCourseOpenRemaindSuccessSuccess:(SuccessBlock)block Failed:(FailureBlock)failre{
    [self.teacherList removeAllObjects];
    NSMutableDictionary *param = [TMUserManager paramDisplay];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_CourseOpenRemind parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSMutableArray *arr = [NSMutableArray array];
        for (NSDictionary *dic in responseObject[@"data"]) {
            TMMyCourseModel *model = [TMMyCourseModel yy_modelWithJSON:dic];
            [arr addObject:model];

        }
        [self.teacherList addObjectsFromArray:arr];
        [TMProgressHUD showSuccessWithStyleDarkStatus:responseObject[@"msg"]];
        block(self.teacherList);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failre(errorMessage);
        [TMProgressHUD showSuccessWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failre(@"1");
    }];
}
#pragma --mark 二维码邀请
- (void)getInvacationCodeWithSuccess:(SuccessBlock)success AndFiled:(FailureBlock)faild{
    NSDictionary *dic = @{@"uid":@([TMUserManager deaufatManager].userModel.uid) ,@"token":[TMUserManager deaufatManager].userModel.token};
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_InvitationCode parameters:dic method:0 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        success(responseObject);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        faild(errorMessage);
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        faild(@"1");
    }];
}
- (void)getInvacationMoneyWithSuccess:(SuccessBlock)success AndFiled:(FailureBlock)faild{
    NSDictionary *dic = @{@"uid":@([TMUserManager deaufatManager].userModel.uid) ,@"token":[TMUserManager deaufatManager].userModel.token};
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_InvitationMoney parameters:dic method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        TMInvitationMoneyModel *model = [TMInvitationMoneyModel yy_modelWithJSON:responseObject];
        success(model);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        faild(errorMessage);
        [TMProgressHUD showSuccessWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        faild(@"1");
    }];
}
#pragma --mark 投诉
- (void)getComplaintWith:(NSString *)phone AndText:(NSString *)text Success:(SuccessBlock)success AndFiled:(FailureBlock)faild{
    NSDictionary *dic = @{@"uid":@([TMUserManager deaufatManager].userModel.uid) ,@"token":[TMUserManager deaufatManager].userModel.token,@"phone":phone ,@"content":text};
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_ComplantPlatform parameters:dic method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        [TMProgressHUD showSuccessWithStyleDarkStatus:@"投诉成功！"];
        success(responseObject);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        faild(errorMessage);
        [TMProgressHUD showSuccessWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        faild(@"1");
    }];
}
- (void)getComplaintBussinessWith:(NSDictionary *)param Success:(SuccessBlock)success AndFiled:(FailureBlock)faild{
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_ComplantBussiness parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        [TMProgressHUD showSuccessWithStyleDarkStatus:@"投诉成功！"];
        success(responseObject);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        faild(errorMessage);
        [TMProgressHUD showSuccessWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        faild(@"1");
    }];
}
#pragma --mark 会员列表
- (void)getVipListWithSuccess:(CompleteBlock)success AndFiled:(FailureBlock)faild{
    [self.teacherList removeAllObjects];
     NSDictionary *dic = @{@"uid":@([TMUserManager deaufatManager].userModel.uid) ,@"token":[TMUserManager deaufatManager].userModel.token};
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_VipList parameters:dic method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
            //NSMutableArray *arr = [NSMutableArray array];
//            TMVipModel *model1 = [TMVipModel yy_modelWithJSON:responseObject[@"self"]];
//            model1.rank = [responseObject[@"rank"] integerValue];
//            [arr addObject:model1];
        for (NSDictionary *dic in responseObject[@"list"]) {
            TMVipModel *model = [TMVipModel yy_modelWithJSON:dic];
            model.end_time = responseObject[@"end_time"];
            model.rank = [responseObject[@"rank"] integerValue];
            model.expiration_time = responseObject[@"expiration_time"];
            [self.teacherList addObject:model];
        }
        success(responseObject[@"rank"] ,self.teacherList);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        faild(errorMessage);
        [TMProgressHUD showSuccessWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        faild(@"1");
    }];
}
#pragma --mark 提现
- (void)getMoneyBackWith:(NSDictionary *)param Success:(SuccessBlock)success AndFiled:(FailureBlock)faild{
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_MoneyBack parameters:param method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        success(responseObject);
        [TMProgressHUD showSuccessWithStyleDarkStatus:@"申请成功！"];
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        faild(errorMessage);
        [TMProgressHUD showSuccessWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        faild(@"1");
    }];
}
#pragma --mark 确认完成
- (void)getSureCommpleteWith:(NSInteger)oid Success:(SuccessBlock)success AndFiled:(FailureBlock)faild{
    NSMutableDictionary *dic = [TMUserManager paramDisplay];
    [dic setValue:@(oid) forKey:@"id"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_SureComplete parameters:dic method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        success(responseObject);
        [TMProgressHUD showSuccessWithStyleDarkStatus:@"订单已确认完成！"];
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        faild(errorMessage);
        [TMProgressHUD showSuccessWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        faild(@"1");
    }];
}

//支付
- (void)getVipOrderPayWithName:(NSDictionary *)dic Success:(SuccessBlock)success AndFiled:(FailureBlock)faild{
    
}
#pragma --mark 购买会员 订单
- (void)commitVipOrderWithName:(NSString *)name Success:(SuccessBlock)success AndFiled:(FailureBlock)faild{
    NSMutableDictionary *dic = [TMUserManager paramDisplay];
    [dic setValue:name forKey:@"name"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_VipCimmitOrder parameters:dic method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        success(responseObject);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        faild(errorMessage);
        [TMProgressHUD showSuccessWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        faild(@"1");
        [TMProgressHUD showSuccessWithStyleDarkStatus:@"网络错误！"];
    }];
}
#pragma --mark --系统消息
-(void)getSysMessageSuccess:(SuccessBlock)success failed:(FailureBlock)failed{
    [self.teacherList removeAllObjects];
    NSMutableDictionary *dic = [TMUserManager paramDisplay];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_SystemMessage parameters:dic method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSMutableArray *arr = [NSMutableArray array];
        for (NSDictionary *dic in responseObject[@"list"]) {
            TMPushModel *model = [TMPushModel yy_modelWithJSON:dic];
            [arr addObject:model];
        }
        [self.teacherList addObjectsFromArray:arr];
        success(self.teacherList);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showSuccessWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showSuccessWithStyleDarkStatus:@"网络错误！"];
    }];
}
#pragma --mark --我的投诉
-(void)getMyCompalitList:(NSInteger)type Success:(SuccessBlock)success failed:(FailureBlock)failed{
    [self.teacherList removeAllObjects];
    NSMutableDictionary *dic = [TMUserManager paramDisplay];
    [dic setValue:@(type) forKey:@"type"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_MyComplaintList parameters:dic method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        NSMutableArray *arr = [NSMutableArray array];
        for (NSDictionary *dic in responseObject[@"list"]) {
            TMComplaintModel *model = [TMComplaintModel yy_modelWithJSON:dic];
            [arr addObject:model];
        }
        [self.teacherList addObjectsFromArray:arr];
        success(self.teacherList);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showSuccessWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showSuccessWithStyleDarkStatus:@"网络错误！"];
    }];
}
#pragma --mark -- 退款
-(void)getMyCanaleMoneyBack:(NSInteger)oid Success:(SuccessBlock)success failed:(FailureBlock)failed{
    NSMutableDictionary *dic = [TMUserManager paramDisplay];
    [dic setValue:@(oid) forKey:@"id"];
    [[TMDataRequest defaultRequest] requestWithPath:TMAPI_CancleMoneyBack parameters:dic method:1 prepareExecute:^{
        
    } success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"%@", responseObject);
        [TMProgressHUD showSuccessWithStyleDarkStatus:@"取消申请成功！"];
        success(responseObject);
    } error:^(NSInteger errorCode, NSString *errorMessage) {
        failed(errorMessage);
        [TMProgressHUD showSuccessWithStyleDarkStatus:errorMessage];
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        failed(@"1");
        [TMProgressHUD showSuccessWithStyleDarkStatus:@"网络错误！"];
    }];
}
@end
